<template>
  <div class="container">
    <div class="leftNaV">
      <el-tree :indent="6" ref="treeList" node-key="id" :data="leftTree" :highlight-current="true"
               :expand-on-click-node="false" @node-click="handleNodeClick" :default-expanded-keys="['all']">
         <span class="custom-tree-node" slot-scope="{ node, data }">
           <span :title="data.label">{{ data.label }}</span>
         </span>
      </el-tree>
      <Corner></Corner>
    </div>
    <div class="rightContent">
      <div class="search">
        <el-form :inline="true" class="demo-form-inline">
          <el-row>
            <el-form-item v-if="addBtn">
              <el-button type="primary" @click="addRegister">新增</el-button>
            </el-form-item>
            <el-form-item v-if="deleteBtn">
              <el-button type="primary" @click="deleteBatch">批量删除</el-button>
            </el-form-item>
            <el-form-item v-if="migrationBtn">
              <el-dropdown @command="dataMigration" trigger="click">
                <el-button type="primary">
                  数据迁移 <i class="el-icon-arrow-down el-icon--right"/>
                </el-button>
                <el-dropdown-menu slot="dropdown" style="background-color: rgb(21 120 176)">
                  <el-dropdown-item :command="false">
                    选择
                  </el-dropdown-item>
                  <el-dropdown-item :command="true">
                    全部
                  </el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </el-form-item>
            <el-form-item v-if="importBtn">
              <el-button type="primary" @click="importVisible = true">导入</el-button>
            </el-form-item>
            <el-form-item v-if="exportBtn">
              <el-dropdown @command="exportTmpVal" trigger="click">
              <el-button type="primary">
                导出<i class="el-icon-arrow-down el-icon--right"/>
              </el-button>
              <el-dropdown-menu slot="dropdown" style="background-color: rgb(21 120 176)">
                <el-dropdown-item :command="false">
                  选择
                </el-dropdown-item>
                <el-dropdown-item :command="true">
                  全部
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown></el-form-item>
          </el-row>
          <el-row>
            <el-form-item>
              <el-input v-model="queryForm.name" class="p-frame" placeholder="请输入种质名称" clearable/>
            </el-form-item>
            <el-form-item>
              <el-input v-model="queryForm.speciesName" class="p-frame" placeholder="请输入种名" clearable/>
            </el-form-item>
            <el-form-item>
              <el-input placeholder="请输入原编号" v-model="queryForm.originalNo" class="p-frame" clearable/>
            </el-form-item>
            <el-form-item>
              <el-select v-model="queryForm.growthEvaluation" class="p-frame" placeholder="请选择生长性状评价" clearable>
                <el-option v-for="(item, i) in evaluates" :key="i" :label="item" :value="item"/>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-select v-model="queryForm.economicEvaluation" class="p-frame" placeholder="请选择经济性状评价" clearable>
                <el-option v-for="(item, i) in evaluates" :key="i" :label="item" :value="item"/>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="query">查询</el-button>
            </el-form-item>
          </el-row>
        </el-form>
      </div>
      <div class="forms">
        <el-table v-loading="loading" :data="tableData" :max-height="635" element-loading-text="拼命加载中"
                  element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)"
                  @select="handleSelect" @select-all="handleSelectAll" border stripe ref="multipleTable">
          <el-table-column align="center" type="selection" v-if="exportBtn"/>
          <el-table-column show-overflow-tooltip label="种质名称" align="center">
            <template slot-scope="scope">
              <span class="pointer" style="margin-left: 10px"
                    @click="showResource(scope.row.id, false)">{{ scope.row.name }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="speciesName" show-overflow-tooltip label="种名" align="center"/>
          <el-table-column prop="originalNo" show-overflow-tooltip label="原编号" align="center"/>
          <el-table-column prop="oneName" show-overflow-tooltip label="保存库名称" align="center"/>
          <el-table-column prop="twoName" show-overflow-tooltip label="保存区名称" align="center"/>
          <el-table-column prop="threeName" show-overflow-tooltip label="树种分区" align="center"/>
          <el-table-column prop="fourName" show-overflow-tooltip label="小区名称" align="center"/>
          <el-table-column prop="germplasm" show-overflow-tooltip label="保存种质" align="center"/>
          <el-table-column prop="type" show-overflow-tooltip label="种质类型" align="center"/>
          <el-table-column prop="amount" show-overflow-tooltip label="植株数量" align="center"/>
          <el-table-column prop="growthEvaluation" show-overflow-tooltip label="生长性状" align="center"/>
          <el-table-column prop="economicEvaluation" show-overflow-tooltip label="经济性状" align="center"/>
          <el-table-column fixed="right" label="操作" align="center" width="400">
            <template slot-scope="scope">
              <span @click="read(scope.row)" class="pointer">查看</span>
              <span v-if="codeBtn" @click="source(scope.row)" class="pointer"><i class="line"></i>溯源</span>
              <span v-if="codeBtn" @click="initCode(scope.row)" class="pointer"><i class="line"></i>扫码</span>
              <span v-if="surveyBtn" class="pointer" @click="addSurvey(scope.row)"><i class="line"></i>调查</span>
              <span v-if="evaluationBtn" class="pointer" @click="addEvaluate(scope.row)"><i class="line"></i>测评</span>
              <span v-if="updateBtn" @click="updateRegister(scope.row)" class="pointer"><i class="line"></i>修改</span>
              <span v-if="deleteBtn" @click="remove(scope.row)" class="pointer"><i class="line"></i>删除</span>
            </template>
          </el-table-column>
        </el-table>
        <div class="paging">
          <el-pagination :page-sizes="[10, 20, 50]" :page-size="this.pageSize" :current-page="pageIndex"
                         :total="totalCount"
                         @current-change="pager" @size-change="handleSizeChange" background
                         layout="total, sizes, prev, pager, next, jumper"/>
        </div>
      </div>
    </div>

    <!-- 林木单份种质弹框 -->
    <el-dialog :title="formTitle" :visible.sync="registerVisible" :before-close="cancel" :close-on-click-modal="false">
      <el-form :model="dataForm" ref="ruleForm" class="demo-ruleForm">
        <div class="form-table_col4">
          <table width="100%">
            <tr>
              <td class="form-item_label">种质名称</td>
              <td>
                <el-input v-model="dataForm.name" @focus="showGather" :disabled="disabled"/>
              </td>
              <td class="form-item_label">库中编号</td>
              <td>
                <el-input v-model="dataForm.code" :disabled="disabled"/>
              </td>
            </tr>
            <tr>
              <td>种名</td>
              <td>
                <el-select filterable v-model="dataForm.speciesName" @change="speciesChange" disabled>
                  <el-option :key="item.id" :label="item.speciesName" :value="item.speciesName"
                             v-for="item in speciesData"/>
                </el-select>
              </td>
              <td>种拉丁名</td>
              <td>
                <el-input class="oblique" v-model="dataForm.speciesLdName" disabled/>
              </td>
            </tr>
            <tr>
              <td class="form-item_label">保存库</td>
              <td>
                <el-select filterable v-model="dataForm.oneId" @change="selectedOne($event, dataForm)" clearable :disabled="disabled">
                  <el-option v-for="item in oneData" :key="item.id" :label="item.name" :value="item.id"/>
                </el-select>
              </td>
              <td class="form-item_label">保存区</td>
              <td>
                <el-select filterable v-model="dataForm.twoId" @change="selectedTwo($event, dataForm)" clearable :disabled="disabled">
                  <el-option v-for="item in twoData" :key="item.id" :label="item.name" :value="item.id"/>
                </el-select>
              </td>
            </tr>
            <tr>
              <td class="form-item_label">树种分区</td>
              <td>
                <el-select filterable v-model="dataForm.threeId" @change="selectedThree($event, dataForm)" clearable :disabled="disabled">
                  <el-option v-for="item in threeData" :key="item.id" :label="item.name" :value="item.id"/>
                </el-select>
              </td>
              <td class="form-item_label">小区</td>
              <td>
                <el-select filterable v-model="dataForm.fourId" clearable :disabled="disabled">
                  <el-option v-for="item in fourData" :key="item.id" :label="item.name" :value="item.id"/>
                </el-select>
              </td>
            </tr>
            <tr>
              <td class="form-item_label">保存种质</td>
              <td>
                <el-select clearable v-model="dataForm.germplasm" :disabled="disabled">
                  <el-option v-for="(item, i) in germplasms" :label="item" :value="item" :key="i"/>
                </el-select>
              </td>
              <td class="form-item_label">种质类型</td>
              <td>
                <el-select multiple filterable allow-create :disabled="disabled" default-first-option placeholder="请输入或选择"
                           v-model="dataForm.type">
                  <el-option v-for="(item, i) in types" :label="item" :value="item" :key="i"/>
                </el-select>
              </td>
            </tr>
            <tr>
              <td>种质来源地</td>
              <td>
                <el-input v-model="dataForm.source" :disabled="disabled"/>
              </td>
              <td class="form-item_label">保存材料来源类型</td>
              <td>
                <el-select clearable v-model="dataForm.materials" :disabled="disabled">
                  <el-option v-for="(item, i) in saMaterials" :label="item" :value="item" :key="i"/>
                </el-select>
              </td>
            </tr>
            <tr>
              <td class="form-item_label">调查分类</td>
              <td>
                <el-select v-model="dataForm.templateId" clearable :disabled="disabled">
                  <el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in templateData"/>
                </el-select>
              </td>
              <td>育苗时间</td>
              <td>
                <el-date-picker v-model="dataForm.seedlingTime" type="date" placeholder="选择日期" value-format="yyyy-MM-dd"
                                :disabled="disabled"/>
              </td>
            </tr>
            <tr>
              <td class="form-item_label">保存时间</td>
              <td>
                <el-date-picker v-model="dataForm.saveTime" type="date" placeholder="选择日期" value-format="yyyy-MM-dd"
                                :disabled="disabled"/>
              </td>
              <td class="form-item_label">植株数量</td>
              <td>
                <el-input-number v-model="dataForm.amount" :min="1" :disabled="disabled"/>
              </td>
            </tr>
            <tr>
              <td>种植密度</td>
              <td>
                <el-input v-model="dataForm.density" :disabled="disabled"/>
              </td>
              <td>库中位置</td>
              <td>
                <div class="td3-box">
                  <LonLat ref="lonRef" @child-event="lonEvent" class="coordinate-type" v-if ="isReady" placeholder="经度" :msg-val="chilLon" :disabled="disabled"/>
                  <LonLat ref="latRef" @child-event="latEvent" class="coordinate-type" v-if ="isReady" placeholder="纬度" :msg-val="chilLat" :disabled="disabled"/>

                  <el-input v-model="dataForm.alt" class="coordinate-type" placeholder="海拔" :disabled="disabled"/>
                </div>
              </td>
            </tr>

            <tr>
              <td>生长性状评价</td>
              <td>
                <el-select filterable v-model="dataForm.growthEvaluation" :disabled="disabled">
                  <el-option :key="'growth' + i" :label="item" :value="item" v-for="(item, i) in evaluates"/>
                </el-select>
              </td>
              <td>经济性状评价</td>
              <td>
                <el-select filterable v-model="dataForm.economicEvaluation" :disabled="disabled">
                  <el-option :key="'economic' + i" :label="item" :value="item" v-for="(item, i) in evaluates"/>
                </el-select>
              </td>
            </tr>
            <tr>
              <td style="display: table-cell; vertical-align: middle">具体用途</td>
              <td colspan="3">
                <el-input type="textarea" v-model="dataForm.purpose" :disabled="disabled"/>
              </td>
            </tr>
            <tr>
              <td style="display: table-cell; vertical-align: middle">生长习性</td>
              <td colspan="3">
                <el-input type="textarea" v-model="dataForm.habit" :disabled="disabled"/>
              </td>
            </tr>
            <tr>
              <td style="display: table-cell; vertical-align: middle">开花结实习性</td>
              <td colspan="3">
                <el-input type="textarea" v-model="dataForm.hsHabit" :disabled="disabled"/>
              </td>
            </tr>
            <tr>
              <td class="form-item_label">收集单位</td>
              <td>
                <SelectTree :options="departmentData" :value="dataForm.collectUnit" :clearable="true" :accordion="false"
                            @getValue="getCollectUnit($event)" :disabled="disabled"/>
              </td>
              <td>登记单位</td>
              <td>
                <SelectTree :options="departmentData" :clearable="true" :accordion="false" :disabled="true"
                            :value="dataForm.registerUnit"/>
              </td>
            </tr>
            <tr>
              <td>登记时间</td>
              <td>
                <el-date-picker v-model="dataForm.registerTime" type="date" placeholder="选择日期" value-format="yyyy-MM-dd"
                                :disabled="disabled"/>
              </td>
              <td>登记人员</td>
              <td>
                <el-input v-model="dataForm.registrant" disabled/>
              </td>
            </tr>
            <tr>
              <td>联系方式</td>
              <td colspan="3">
                <el-input v-model="dataForm.registrantPhone" disabled/>
              </td>
            </tr>
            <tr>
              <td style="display: table-cell; vertical-align: middle">备注</td>
              <td colspan="3">
                <el-input type="textarea" v-model="dataForm.remark" :disabled="disabled"/>
              </td>
            </tr>
          </table>
          <div style="margin-top: 20px">
            <!-- <el-upload class="upload-demo" ref="upload" action="" :on-change="handleChange" :on-remove="handleRemove"
                :file-list="fileList" :auto-upload="false">
                <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
            </el-upload> -->
            <el-form-item label="图片上传:">
              <el-upload action="#" list-type="picture-card" :file-list="fileList" :auto-upload="false"
                         :on-change="handleChange" :accept="'image/*'" :disabled="disabled">
                <i slot="default" class="el-icon-plus"></i>
                <div slot="file" slot-scope="{ file }">
                  <img class="el-upload-list__item-thumbnail" :src="file.url" alt="" style="min-height: 146px"/>
                  <span class="el-upload-list__item-actions">
                    <span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
                      <i class="el-icon-zoom-in"></i>
                    </span>
                    <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file)">
                      <i class="el-icon-delete"></i>
                    </span>
                  </span>
                </div>
              </el-upload>
              <div class="preview">
                <el-dialog title="预览" :visible.sync="dialogVisible" :modal="false" width="1200px" top="50px">
                  <img :src="dialogImageUrl" alt=""/>
                </el-dialog>
              </div>
            </el-form-item>
          </div>
        </div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button v-if="formEdit !== 'read'" class="dialogBtn" type="primary" @click="saveRegister">保 存</el-button>
        <el-button type="primary" @click="cancel" class="dialogBtn">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 溯源弹框 -->
    <el-dialog title="查看采集登记" :visible.sync="sourceVisible" width="850px">
      <el-form :model="gatherRowForm" ref="ruleForm" class="demo-ruleForm">
        <div class="form-table_col4">
          <table border="1" width="100%">
            <tr>
              <td class="form-item_label" style="display: table-cell; vertical-align: middle">
                种质名称
              </td>
              <td colspan="3">
                <el-input v-model="gatherRowForm.grName" disabled/>
              </td>
            </tr>
            <tr>
              <td class="form-item_label" style="display: table-cell; vertical-align: middle">
                原编号
              </td>
              <td>
                <el-input v-model="gatherRowForm.originalNo" disabled/>
              </td>
              <td class="form-item_label">种质来源</td>
              <td>
                <el-select clearable v-model="gatherRowForm.source" disabled>
                  <el-option v-for="(item, i) in source" :key="i" :label="item" :value="item"/>
                </el-select>
              </td>
            </tr>
            <tr>
              <td class="form-item_label">种名</td>
              <td>
                <el-select filterable v-model="gatherRowForm.speName" clearable disabled>
                  <el-option :key="item.id" :label="item.speciesName" :value="item.speciesName"
                             v-for="item in speciesData"/>
                </el-select>
              </td>
              <td>拉丁名</td>
              <td>
                <el-input class="oblique" v-model="gatherRowForm.speLaName" disabled/>
              </td>
            </tr>
            <tr>
              <td class="form-item_label">生活型</td>
              <td>
                <el-select clearable v-model="gatherRowForm.lifeStyle" disabled>
                </el-select>
              </td>
              <td class="form-item_label">常绿性</td>
              <td>
                <el-select clearable v-model="gatherRowForm.evergreen" disabled>
                </el-select>
              </td>
            </tr>
            <tr>
              <td class="form-item_label">种质来源类型</td>
              <td>
                <el-select clearable v-model="gatherRowForm.sourceType" disabled>
                </el-select>
              </td>
              <td class="form-item_label">主要特性</td>
              <td>
                <el-select multiple filterable allow-create default-first-option disabled placeholder="请选择主要特性"
                           v-model="gatherRowForm.feaMain">
                </el-select>
              </td>
            </tr>
            <tr>
              <td style="display: table-cell; vertical-align: middle">
                特异性特征
              </td>
              <td colspan="3">
                <el-input type="textarea" v-model="gatherRowForm.feaSpec" disabled/>
              </td>
            </tr>
            <tr>
              <td class="form-item_label">用途</td>
              <td>
                <el-select multiple filterable allow-create disabled default-first-option placeholder="请选择用途"
                           v-model="gatherRowForm.purpose">
                </el-select>
              </td>
              <td style="display: table-cell; vertical-align: middle">
                种质来源地
              </td>
              <td>
                <el-input v-model="gatherRowForm.grSource" disabled/>
              </td>
            </tr>
            <tr>
              <td style="display: table-cell; vertical-align: middle">
                原产地备注
              </td>
              <td colspan="3">
                <el-input type="textarea" v-model="gatherRowForm.remarksCo" disabled/>
              </td>
            </tr>
            <tr>
              <td style="display: table-cell; vertical-align: middle">
                种质来源地备注
              </td>
              <td colspan="3">
                <el-input type="textarea" v-model="gatherRowForm.remarksSt" disabled/>
              </td>
            </tr>
            <tr>
              <td style="display: table-cell; vertical-align: middle">
                林分面积
              </td>
              <td>
                <el-input v-model="gatherRowForm.standArea" disabled/>
              </td>
              <td style="display: table-cell; vertical-align: middle">林龄</td>
              <td>
                <el-input v-model="gatherRowForm.forestAge" disabled/>
              </td>
            </tr>
            <tr>
              <td style="display: table-cell; vertical-align: middle">林相</td>
              <td colspan="3">
                <el-input v-model="gatherRowForm.forestApp" disabled/>
              </td>
            </tr>
            <tr>
              <td class="form-item_label" style="display: table-cell; vertical-align: middle">
                采集点联系人
              </td>
              <td>
                <el-input v-model="gatherRowForm.coContacts" disabled/>
              </td>
              <td class="form-item_label" style="display: table-cell; vertical-align: middle">
                采集点联系电话
              </td>
              <td>
                <el-input v-model="gatherRowForm.coPhone" disabled/>
              </td>
            </tr>
            <tr>
              <td class="form-item_label" style="display: table-cell; vertical-align: middle">
                采集人
              </td>
              <td>
                <el-input v-model="gatherRowForm.collector" disabled/>
              </td>
              <td class="form-item_label" style="display: table-cell; vertical-align: middle">
                采集时间
              </td>
              <td>
                <el-date-picker v-model="gatherRowForm.coTime" type="date" placeholder="选择日期" disabled/>
              </td>
            </tr>
            <tr>
              <td style="display: table-cell; vertical-align: middle">
                登记人员
              </td>
              <td colspan="3">
                <el-input v-model="gatherRowForm.regPer" disabled/>
              </td>
            </tr>
            <tr>
              <td style="display: table-cell; vertical-align: middle">
                登记单位
              </td>
              <td>
                <SelectTree :options="departmentData" :value="gatherRowForm.regUnit" :clearable="true"
                            :accordion="false"
                            disabled/>
              </td>
              <td style="display: table-cell; vertical-align: middle">
                登记时间
              </td>
              <td>
                <el-date-picker v-model="gatherRowForm.regTime" disabled type="date" placeholder="选择日期"/>
              </td>
            </tr>
            <tr>
              <td style="display: table-cell; vertical-align: middle">经度</td>
              <td>
                <el-input v-model="gatherRowForm.lon" disabled/>
              </td>
              <td style="display: table-cell; vertical-align: middle">纬度</td>
              <td>
                <el-input v-model="gatherRowForm.lat" disabled/>
              </td>
            </tr>
            <tr>
              <td style="display: table-cell; vertical-align: middle">高度</td>
              <td>
                <el-input v-model="gatherRowForm.alt" disabled/>
              </td>
              <td style="display: table-cell; vertical-align: middle">坡位</td>
              <td>
                <el-input v-model="gatherRowForm.slPos" disabled/>
              </td>
            </tr>
            <tr>
              <td style="display: table-cell; vertical-align: middle">坡向</td>
              <td>
                <el-input v-model="gatherRowForm.aspect" disabled/>
              </td>
              <td style="display: table-cell; vertical-align: middle">坡度</td>
              <td>
                <el-input v-model="gatherRowForm.slope" disabled/>
              </td>
            </tr>
            <tr>
              <td style="display: table-cell; vertical-align: middle">
                土壤类型
              </td>
              <td>
                <el-select clearable v-model="gatherRowForm.soilType" disabled>
                </el-select>
              </td>
              <td style="display: table-cell; vertical-align: middle">
                立地条件
              </td>
              <td>
                <el-input v-model="gatherRowForm.siteCond" disabled/>
              </td>
            </tr>
            <tr>
              <td style="display: table-cell; vertical-align: middle">备注</td>
              <td colspan="3">
                <el-input type="textarea" v-model="gatherRowForm.remarks" disabled/>
              </td>
            </tr>
          </table>
        </div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="sourceVisible = false" class="dialogBtn">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 野外采集列表弹框 -->
    <el-dialog title="野外采集列表" custom-class="dialogs" :visible.sync="gatherVisible" :before-close="cancelGather"
               :close-on-click-modal="false">
      <div class="search">
        <el-form :inline="true" class="demo-form-inline">
          <el-form-item>
            <el-input placeholder="种质名称" v-model="gatherForm.ggName" class="p-frame" clearable/>
          </el-form-item>
          <el-form-item>
            <el-input placeholder="请输入原编号" v-model="gatherForm.originalNo" class="p-frame" clearable/>
          </el-form-item>
          <!--          <el-form-item>
                      <el-date-picker class="p-frame" type="daterange" start-placeholder="开始日期" range-separator="至"
                        end-placeholder="结束日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd HH:mm:ss" v-model="gatherForm.createDate"
                        :default-time="['00:00:00', '23:59:59']" />
                    </el-form-item>-->
          <el-form-item>
            <el-button type="primary" class="upload" @click="queryGather">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div class="forms">
        <el-table border stripe class="tableLine" :data="gatherTableData" ref="multipleTable"
                  @row-click="checkedTableRows">
          <el-table-column prop="grName" show-overflow-tooltip label="采集种质名称" align="center"/>
          <el-table-column prop="speName" show-overflow-tooltip label="种名" align="center"/>
          <el-table-column prop="speLaName" show-overflow-tooltip label="种拉丁名" align="center"/>
          <el-table-column prop="originalNo" show-overflow-tooltip label="原编号" align="center"/>
          <el-table-column prop="source" show-overflow-tooltip label="种质来源" align="center"/>
          <el-table-column prop="sourceType" show-overflow-tooltip label="种质来源类型" align="center"/>
        </el-table>
      </div>
      <div slot="footer" class="dialog-footer">
        <div class="paging">
          <el-pagination :page-sizes="[8]" :page-size="gatherSize" :current-page="gatherIndex" :total="gatherTotalCount"
                         @current-change="gatherPager" background layout="total, sizes, prev, pager, next, jumper"/>
        </div>
      </div>
    </el-dialog>

    <!-- 二维码弹框 -->
    <el-dialog width="540px" title="扫码查看详情" :close-on-click-modal="false" :visible.sync="qrCodeVisible">
      <div style="margin: 0 auto; text-align: center;">
        <canvas id="QRCode" style="margin: 0 auto" ref="qrCodeDiv"/>
      </div>
      <div style="display: flex;justify-content: space-between;margin-top:28px">
        <div><span>种质名称：</span><span style="color: #0fff;">{{ tableRow.name }}</span></div>
        <div><span>种名：</span><span style="color: #0fff;">{{ tableRow.speciesName }}</span></div>
        <div><span>拉丁名：</span><span style="color: #0fff;font-style:oblique;">{{ tableRow.speciesLdName }}</span></div>
      </div>
      <div class="dialog-footer" slot="footer">
        <el-button @click="qrCodeVisible = false" class="dialogBtn" type="primary">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 新增/查询调查数据弹框 -->
    <el-dialog :title="surveyTitle" :visible.sync="surveyVisible" :before-close="cancelSurvey"
               :close-on-click-modal="false">
      <el-form class="single_3column" labelPosition='left' :inline="true" label-width="140px" ref="rules"
               :model="surveyForm">
        <div class="table-all"
             style="width: calc(100%);box-sizing: border-box;margin: 10px auto 20px auto;border: 1px solid #D3D3D3;">
          <el-collapse v-model="active" accordion>
            <el-collapse-item title="基本信息" name="1">
              <div class="qr-ul">
                <div class="table-td2">植株编号<span style="color:#B22222">*</span>:</div>
                <div class="table-td3">
                  <el-input class="td-input" :disabled="surveyDisable" v-model="surveyForm.number"></el-input>
                </div>
                <div class="table-td2">种质名称:</div>
                <div class="table-td3">
                  <el-input class="td-input" :disabled="true" v-model="surveyForm.name"/>
                </div>
              </div>

              <div class="qr-ul">
                <div class="table-td2"><span style="color:#B22222">*</span>保存库:</div>
                <div class="table-td3">
<!--                  <el-select filterable v-model="surveyForm.oneId" @change="selectedOne" clearable :disabled="false">
                    <el-option v-for="item in oneData" :key="item.id" :label="item.name" :value="item.id"/>
                  </el-select>-->
                  <el-input class="td-input" v-model="surveyForm.oneName" disabled />
                </div>
                <div class="table-td2"><span style="color:#B22222">*</span>保存区:</div>
                <div class="table-td3">
<!--                  <el-select filterable v-model="surveyForm.twoId" @change="selectedTwo" clearable :disabled="false">
                    <el-option v-for="item in twoData" :key="item.id" :label="item.name" :value="item.id"/>
                  </el-select>-->
                  <el-input class="td-input" v-model="surveyForm.twoName" disabled />
                </div>
              </div>
              <div class="qr-ul">
                <div class="table-td2"><span style="color:#B22222">*</span>树种分区:</div>
                <div class="table-td3">
                  <el-input class="td-input" v-model="surveyForm.threeName" disabled/>
<!--                  <el-select filterable v-model="surveyForm.threeId" @change="selectedThree" clearable
                             :disabled="false">
                    <el-option v-for="item in threeData" :key="item.id" :label="item.name" :value="item.id"/>
                  </el-select>-->
                </div>
                <div class="table-td2"><span style="color:#B22222">*</span>小区:</div>
                <div class="table-td3">
<!--                  <el-select filterable v-model="surveyForm.fourId" clearable :disabled="false">
                    <el-option v-for="item in fourData" :key="item.id" :label="item.name" :value="item.id"/>
                  </el-select>-->
                  <el-input class="td-input" v-model="surveyForm.fourName" disabled />
                </div>
              </div>
              <div class="qr-ul">
                <div class="table-td2">种质分类:</div>
                <div class="table-td3">
                  <el-select filterable v-model="surveyForm.type" placeholder="请选择" :disabled="true">
                    <el-option v-for="(item, i) in types" :key="i" :label="item" :value="item"/>
                  </el-select>
                </div>
                <div class="table-td2">经度:</div>
                <div class="table-td3">
                  <LonLat ref="lonRef" @child-event="lonDiChaEvent"  v-if ="isReady" :msg-val="chilLon" :disabled="surveyDisable"/>
                </div>
              </div>
              <div class="qr-ul">
                <div class="table-td2">纬度:</div>
                <div class="table-td3">
                  <LonLat ref="latRef" @child-event="latDiChaEvent"  v-if ="isReady"  :msg-val="chilLat" :disabled="surveyDisable"/>
                </div>
                <div class="table-td2">海拔:</div>
                <div class="table-td3">
                  <el-input class="td-input" :disabled="surveyDisable" v-model="surveyForm.alt"/>
                </div>
              </div>
            </el-collapse-item>
            <el-collapse-item class="dynamic" :title="template.name" :key="index" :name="(index + 2)"
                              v-for="(template, index) in templateDetails">
              <div v-for="(item, i) in template.items" :key="i" class="qr-ul">
                <div class="table-td2">{{ item.name }}:</div>
                <div class="table-td3" v-if="item.type === 'input'">
                  <el-input class="td-input" :disabled="surveyDisable" v-model="dataJson[item.name]"/>
                </div>
                <div class="table-td3" v-else-if="item.type === 'number'">
                  <el-input-number :disabled="surveyDisable" v-model="dataJson[item.name]"/>
                </div>
                <div class="table-td3" v-else-if="item.type === 'select'">
                  <el-select filterable v-model="dataJson[item.name]" placeholder="请选择" :disabled="surveyDisable">
                    <el-option v-for="subItem in item.children" :key="subItem.id" :label="subItem.name"
                               :value="subItem.name"/>
                  </el-select>
                </div>
                <div class="table-td3" v-else-if="item.type === 'upload'" style="text-align:center">
                  <a v-if="!surveyEdit" target="_blank" :href="fileServerUrl + dataJson[item.name]">
                    <span v-if="dataJson[item.name] && dataJson[item.name].length > 0">
                      {{ dataJson[item.name].substring(dataJson[item.name].lastIndexOf('/') + 1, dataJson[item.name].length) }}
                    </span>
                  </a>
                  <el-upload v-else class="upload-demo" :action="uploadAction" :multiple="false" :limit="1"
                             :name="item.name"
                             :disabled="surveyDisable" :file-list="setFileList(dataJson[item.name])"
                             :on-exceed="handleExceed"
                             :http-request="uploadFile">
                    <el-button size="small" type="primary">选取文件</el-button>
                  </el-upload>
                </div>
                <div class="table-td3" v-else-if="item.type === 'data'">
                  <el-date-picker v-model="dataJson[item.name]" type="datetime" :disabled="surveyDisable"
                                  value-format="yyyy-MM-dd HH:mm:ss"
                                  placeholder="选择日期时间"/>
                </div>
              </div>
            </el-collapse-item>
          </el-collapse>
        </div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button v-if="surveyEdit" class="dialogBtn" type="primary" @click="saveSurvey">保 存</el-button>
        <el-button class="dialogBtn" type="primary" @click="cancelSurvey">关 闭</el-button>
      </div>
    </el-dialog>

    <!-- 调查数据列表弹框 -->
    <el-dialog :width="'70%'" title="调查数据列表" :visible.sync="resourceVisible" :before-close="cancelResource"
               :close-on-click-modal="false">
      <el-table border stripe class="tableLine" ref="resourceTable" :data="resourceTableData" @select="handleSelection"
                @select-all="handleSelectionAll" @selection-change="selectionChange">
        <el-table-column type="selection" align="center" width="55"/>
        <el-table-column prop="createDate" show-overflow-tooltip label="调查时间" align="center"/>
        <el-table-column prop="number" show-overflow-tooltip label="植株编号" align="center"/>
        <el-table-column prop="name" show-overflow-tooltip label="种质名称" align="center"/>
        <el-table-column prop="type" show-overflow-tooltip label="种质分类" align="center"/>
        <el-table-column prop="createName" show-overflow-tooltip label="调查人" align="center"/>
        <el-table-column prop="lon" show-overflow-tooltip label="经度" align="center"/>
        <el-table-column prop="lat" show-overflow-tooltip label="纬度" align="center"/>
        <el-table-column prop="alt" show-overflow-tooltip label="海拔" align="center"/>
        <el-table-column fixed="right" label="操作" align="center">
          <template slot-scope="scope">
            <span @click="getSurvey(scope.row)" class="pointer">查看</span>
          </template>
        </el-table-column>
      </el-table>
      <div class="footer">
        <div class="paging info">
          <el-pagination :page-sizes="[8]" :page-size="resourceSize" :current-page="resourceIndex"
                         :total="resourceTotalCount"
                         @current-change="resourcePager" background layout="total, sizes, prev, pager, next"/>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button v-if="resourceEdit" @click="getNumber" type="primary" class="dialogBtn">确 定</el-button>
        <el-button type="primary" @click="cancelResource" class="dialogBtn">关 闭</el-button>
      </div>
    </el-dialog>

    <!-- 新增测定评价弹框 -->
    <el-dialog title="测定评价" :visible.sync="evaluateVisible" :before-close="cancelEvaluate"
               :close-on-click-modal="false">
      <el-form :model="evaluateForm" label-width="160px" class="demo-ruleForm">
        <div class="form-table">
          <table>
            <tr>
              <td class="form-item_label">物种名称</td>
              <td>
                <el-input class="td-input" v-model="evaluateForm.name" disabled/>
              </td>
              <td>定值年份</td>
              <td>
                <el-date-picker v-model="evaluateForm.decideYear" type="year" value-format="yyyy" placeholder="选择年份"/>
              </td>
            </tr>
            <tr>
              <td>种名( 中文、拉丁 )</td>
              <td>
                <el-input class="td-input" v-model="evaluateForm.specificName" disabled/>
              </td>
              <td>科名( 中文、拉丁 )</td>
              <td>
                <el-input class="td-input" v-model="evaluateForm.familyName" disabled/>
              </td>
            </tr>
            <tr>
              <td class="form-item_label">保存库名称</td>
              <td>
                <el-input class="td-input" v-model="evaluateForm.oneName" disabled/>
              </td>
              <td class="form-item_label">保存区名称</td>
              <td>
                <el-input class="td-input" v-model="evaluateForm.twoName" disabled/>
              </td>
            </tr>
            <tr>
              <td class="form-item_label">树种分区</td>
              <td>
                <el-input class="td-input" v-model="evaluateForm.threeName" disabled/>
              </td>
              <td class="form-item_label">小区</td>
              <td>
                <el-input class="td-input" v-model="evaluateForm.fourName" disabled/>
              </td>
            </tr>
            <tr>
              <td>种质名称</td>
              <td>
                <el-input class="td-input" v-model="evaluateForm.germplasmName" disabled/>
              </td>
              <td>保存种质类型</td>
              <td>
                <el-input class="td-input" v-model="evaluateForm.germplasmType" disabled/>
              </td>
            </tr>
            <tr>
              <td>用途</td>
              <td>
                <el-input class="td-input" v-model="evaluateForm.purpose" disabled/>
              </td>
              <td>植株编号</td>
              <td>
                <el-input class="td-input" readonly v-model="evaluateForm.resourceNumber"
                          @focus="showResource(evaluateForm.registerGatherId, true)"/>
              </td>
            </tr>
            <tr>
              <td>保存时间</td>
              <td>
                <el-date-picker type="date" placeholder="选择日期" value-format="yyyy-MM-dd" disabled
                                v-model="evaluateForm.saveTime"/>
              </td>
              <td>库中位置</td>
              <td>
                <el-input v-model="evaluateForm.lon" placeholder="经度" class="coordinate" disabled/>
                <span>-</span>
                <el-input v-model="evaluateForm.lat" placeholder="纬度" class="coordinate" disabled/>
                <span>-</span>
                <el-input v-model="evaluateForm.alt" placeholder="海拔" class="coordinate" disabled/>
              </td>
            </tr>
            <tr>
              <td>繁殖方式</td>
              <td>
                <el-input class="td-input" v-model="evaluateForm.breedMode"/>
              </td>
              <td>苗龄</td>
              <td>
                <el-input class="td-input" v-model="evaluateForm.stockAge"/>
              </td>
            </tr>
            <tr>
              <td>平均树高(m)</td>
              <td>
                <el-input class="td-input" v-model="evaluateForm.avgHigh"/>
              </td>
              <td>平均胸径(cm)</td>
              <td>
                <el-input class="td-input" v-model="evaluateForm.avgDbh"/>
              </td>
            </tr>
            <tr>
              <td>平均冠幅(m,东西)</td>
              <td>
                <el-input class="td-input" v-model="evaluateForm.avgPew"/>
              </td>
              <td>平均冠幅(m,南北)</td>
              <td>
                <el-input class="td-input" v-model="evaluateForm.avgPsn"/>
              </td>
            </tr>
            <tr>
              <td style="display:table-cell;vertical-align:middle">生产及经济性状评价</td>
              <td colspan="3">
                <el-input type="textarea" v-model="evaluateForm.productionEvaluate"/>
              </td>
            </tr>
            <tr>
              <td style="display:table-cell;vertical-align:middle">生长及抗逆性评价</td>
              <td colspan="3">
                <el-input type="textarea" v-model="evaluateForm.growEvaluate"/>
              </td>
            </tr>
            <tr>
              <td>特殊性状</td>
              <td>
                <el-input class="td-input" v-model="evaluateForm.specialCharacters"/>
              </td>
              <td style="display:table-cell; vertical-align:middle">综合评价</td>
              <td>
                <el-select filterable v-model="evaluateForm.comprehensiveAssessment" clearable>
                  <el-option v-for="(item, i) in composite" :label="item" :value="item" :key="i"/>
                </el-select>
              </td>
            </tr>
            <tr>
              <td>测定人员</td>
              <td>
                <el-input class="td-input" v-model="evaluateForm.personnel"/>
              </td>
              <td>测定时间</td>
              <td>
                <el-date-picker type="date" placeholder="选择日期" value-format="yyyy-MM-dd"
                                v-model="evaluateForm.determinationTime"/>
              </td>
            </tr>
            <tr>
              <td style="display:table-cell;vertical-align:middle">备注</td>
              <td colspan="3">
                <el-input type="textarea" v-model="evaluateForm.remark"/>
              </td>
            </tr>
          </table>
        </div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="saveEvaluate" class="dialogBtn">保 存</el-button>
        <el-button type="primary" @click="cancelEvaluate" class="dialogBtn">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog title="导入保存登记" :visible.sync="importVisible" class="import" width="30%" :close-on-click-modal="false">
      <div style="text-align: center">
        <el-upload drag :action="importAction" class="upload-demo" :show-file-list="false"
                   :headers="uploadHeader" :before-upload="beforeUpload" :on-success="handleSuccess">
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
          <div class="el-upload__tip" slot="tip">
            只能上传xls/xlsx文件，
            <el-button type="text" @click="downloadExcel">下载模板</el-button>
          </div>
        </el-upload>
      </div>
    </el-dialog>

    <el-dialog title="数据迁移" :visible.sync="migrationVisible" :before-close="migrationCancel" :close-on-click-modal="false">
      <el-form :model="migration" ref="migration">
        <div class="form-table_col4">
          <table width="100%">
            <tr>
              <td class="form-item_label">保存库</td>
              <td>
                <el-select filterable v-model="migration.oneId" @change="selectedOne($event, migration)" clearable>
                  <el-option v-for="item in oneData" :key="item.id" :label="item.name" :value="item.id"/>
                </el-select>
              </td>
              <td class="form-item_label">保存区</td>
              <td>
                <el-select filterable v-model="migration.twoId" @change="selectedTwo($event, migration)" clearable>
                  <el-option v-for="item in twoData" :key="item.id" :label="item.name" :value="item.id"/>
                </el-select>
              </td>
            </tr>
            <tr>
              <td class="form-item_label">树种分区</td>
              <td>
                <el-select filterable v-model="migration.threeId" @change="selectedThree($event, migration)" clearable >
                  <el-option v-for="item in threeData" :key="item.id" :label="item.name" :value="item.id"/>
                </el-select>
              </td>
              <td class="form-item_label">小区</td>
              <td>
                <el-select filterable v-model="migration.fourId" clearable>
                  <el-option v-for="item in fourData" :key="item.id" :label="item.name" :value="item.id"/>
                </el-select>
              </td>
            </tr>
          </table>
        </div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button class="dialogBtn" type="primary" @click="saveMigration">迁移</el-button>
        <el-button type="primary" @click="migrationCancel" class="dialogBtn">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import QRCode from 'qrcode'
import Corner from '../../../components/corner'
import SelectTree from '@/components/TreeSelect'
import resourceApi from '@/api/resourceApi'
import systemApi from '../../../api/systemApi'
import templateApi from '../../../api/templateApi'
import ResourceManageApi from '../../../api/ResourceManageApi'
import LonLat from '../../../components/LatLon'

Date.prototype.Format = function (fmt) {
  var o = {
    'M+': this.getMonth() + 1, // 月份
    'd+': this.getDate(), // 日
    'h+': this.getHours(), // 小时
    'm+': this.getMinutes(), // 分
    's+': this.getSeconds(), // 秒
    'q+': Math.floor((this.getMonth() + 3) / 3), // 季度
    'S': this.getMilliseconds() // 毫秒
  }
  if (/(y+)/.test(fmt)) {
    fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
  }
  for (var k in o) {
    if (new RegExp('(' + k + ')').test(fmt)) {
      fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
    }
  }
  return fmt
}

export default {
  name: 'RegisterSave',
  components: {
    Corner,
    SelectTree,
    LonLat
  },
  data () {
    return {
      loading: false,
      leftTree: [],
      selectedNode: null,
      condition: 'growthEvaluation',
      queryForm: {},
      pageIndex: 1,
      pageSize: 10,
      totalCount: 0,
      tableData: [],
      tableRow: {},
      departmentData: [],
      dataForm: {},
      formTitle: null,
      formEdit: null,
      registerVisible: false,
      gatherVisible: false,
      sourceVisible: false,
      speciesData: [],
      templateData: [],
      oneData: [],
      twoData: [],
      threeData: [],
      fourData: [],
      germplasms: ['保存', '备份', '重复'],
      types: ['群体（种源、林分）', '家系', '个体（优树、无性系）', '地方品种', '选育品种', '育种材料（优良林分、优树、半同胞家系、全同胞家系、杂交后代、无性系）'],
      saMaterials: ['植株', '种子', '营养器官（穗条、块根；根穗、根鞭等）', '培养物（组培材料）', '其他'],
      gatherForm: {},
      gatherRowForm: {},
      gatherIndex: 1,
      gatherSize: 8,
      gatherTotalCount: 0,
      gatherTableData: [],
      qrCodeVisible: false,
      active: '1',
      surveyEdit: false,
      surveyForm: {},
      surveyTitle: null,
      surveyDisable: false,
      surveyVisible: false,
      dataJson: {},
      templateDetails: [],
      fileServerUrl: process.env.FILE_SERVER,
      uploadAction: process.env.SURVEY_DOMAIN + '/accessory/uploadFile',
      registerSaveId: null,
      resourceIndex: 1,
      resourceSize: 8,
      resourceEdit: false,
      resourceTotalCount: 0,
      resourceTableData: [],
      resourceVisible: false,
      multipleSelection: [],
      evaluateVisible: false,
      evaluateForm: {},
      composite: ['好', '较好', '一般', '较差', '差'],
      evaluates: ['优', '好', '中', '差'],
      speciesMap: {},
      disabled: false,
      addBtn: false,
      updateBtn: false,
      deleteBtn: false,
      importBtn: false,
      exportBtn: false,
      codeBtn: false,
      surveyBtn: false,
      evaluationBtn: false,
      migrationBtn: false,
      importAction: process.env.SURVEY_DOMAIN + '/gr/register/save/excelImport',
      uploadHeader: {
        token: `${window.localStorage.token}`
      },
      importVisible: false,
      onlyId: [],
      fileList: [],
      dialogVisible: false,
      dialogImageUrl: '',
      chilLon:'',
      chilLat:'',
      isReady:false,
      migration: {},
      migrationVisible: false
    }
  },
  created () {
    this.initBtn();
    this.findTree();
    this.findPage();
    this.findSpecies();
    this.findTemplate();
    this.findDepartment();
  },
  methods: {
    findTree () {
      this.leftTree = [{
        id: 'all',
        label: '全部',
        children: []
      }]
      ResourceManageApi.getTree().then(res => {
        let result = res.data.result
        if (res.data.message === 'success' && result) {
          this.leftTree[0].children = result
        }
      })
    },
    handleNodeClick (data) {
      this.queryForm.oneId = null;
      this.queryForm.twoId = null;
      this.queryForm.threeId = null;
      this.queryForm.fourId = null;
      this.selectedNode = data.id === 'all' ? null : data
      if (this.selectedNode) {
        let id = this.selectedNode.id;
        let module = this.selectedNode.module;
        if (module === 'one') {
          this.queryForm.oneId = id;
        } else if (module === 'two') {
          this.queryForm.twoId = id;
        } else if (module === 'three') {
          this.queryForm.threeId = id;
        } else if (module === 'four') {
          this.queryForm.fourId = id;
        }
      }
      this.query()
    },
    query () {
      this.pageIndex = 1
      this.clearSelection()
      this.findPage()
    },
    findPage () {
      this.loading = true;
      let params = Object.assign({}, this.queryForm);
      params.pageSize = this.pageSize;
      params.pageIndex = this.pageIndex;
      resourceApi.findRegisterPreservationPage(params).then(res => {
        this.loading = false
        let result = res.data.result
        if (res.data.message === 'success' && result) {
          this.totalCount = result.totalCount
          this.tableData = result.rows
          let onlyId = this.onlyId
          if (onlyId.length > 0) {
            this.$nextTick(() => {
              this.tableData.forEach((row) => {
                for (let i in onlyId) {
                  let id = onlyId[i]
                  if (row.id === id) {
                    this.$refs.multipleTable.toggleRowSelection(row)
                    break
                  }
                }
              })
            })
          }
        } else {
          this.totalCount = 0
          this.tableData = []
        }
      })
    },
    pager (val) {
      this.pageIndex = val
      this.findPage()
    },
    handleSizeChange (val) {
      this.pageSize = val
      this.findPage()
    },
    findDepartment () {
      systemApi.getDeparmentList().then((res) => {
        if (res.data.message === 'success') {
          this.departmentData = res.data.result
        } else {
          this.departmentData = []
        }
      })
    },
    findSpecies () {
      this.speciesMap = {};
      this.speciesData = [];
      resourceApi.findSpecies().then((res) => {
        let result = res.data.result;
        if (res.data.message === 'success' && result) {
          this.speciesData = result;
          for (let i in result) {
            this.$set(this.speciesMap, result[i].speciesName, result[i]);
          }
        }
      })
    },
    findTemplate () {
      templateApi.findTemplate('TEMPLATE').then(res => {
        if (res.data.message === 'success') {
          this.templateData = res.data.result
        } else {
          this.templateData = []
        }
      })
    },
    getOne () {
      this.getModule('one').then(res => {
        this.oneData = res
      })
    },
    async getModule (module) {
      let result = []
      let res = await ResourceManageApi.getModule(module)
      if (res.data.message === 'success') {
        result = res.data.result
      }
      return result
    },
    async getChildren (data) {
      let result = []
      if (data) {
        let res = await ResourceManageApi.getChildren(data)
        if (res.data.message === 'success') {
          result = res.data.result
        }
      }
      return result
    },
    selectedOne (data, form) {
      this.twoData = []
      this.threeData = []
      this.fourData = []
      this.$set(form, 'twoId', null)
      this.$set(form, 'threeId', null)
      this.$set(form, 'fourId', null)
      if (data) {
        this.getChildren(data).then(res => {
          this.twoData = res
        })
      }
    },
    selectedTwo (data, form) {
      this.threeData = []
      this.fourData = []
      this.$set(form, 'threeId', null)
      this.$set(form, 'fourId', null)
      if (data) {
        this.getChildren(data).then(res => {
          this.threeData = res
        })
      }
    },
    selectedThree (data, form) {
      this.fourData = []
      this.$set(form, 'fourId', null)
      if (data) {
        this.getChildren(data).then(res => {
          this.fourData = res
        })
      }
    },
    validation () {
      let flag = true
      let message = null
      if (!this.dataForm.name) {
        flag = false
        message = '请选择种质名称'
      }

      if (flag && !this.dataForm.code) {
        flag = false
        message = '请输入种质编号'
      }
      if (flag && !this.dataForm.oneId) {
        flag = false
        message = '请选择保存库'
      }
      if (flag && !this.dataForm.twoId) {
        flag = false
        message = '请选择保存区'
      }
      if (flag && !this.dataForm.threeId) {
        flag = false
        message = '请选择隶属大类'
      }
      if (flag && !this.dataForm.fourId) {
        flag = false
        message = '请选择小区'
      }
      if (flag && !this.dataForm.germplasm) {
        flag = false
        message = '请选择保存种质'
      }

      if (flag && (!this.dataForm.type || this.dataForm.type.length < 1)) {
        flag = false
        message = '请选择种质类型'
      }

      if (flag && !this.dataForm.materials) {
        flag = false
        message = '请选择保存材料来源类型'
      }

      if (flag && !this.dataForm.templateId) {
        flag = false
        message = '请选择调查分类'
      }

      if (flag && !this.dataForm.saveTime) {
        flag = false
        message = '请选择保存时间'
      }
      if (flag && !this.dataForm.amount) {
        flag = false
        message = '请输入植株数量'
      }
      if (flag && !this.dataForm.collectUnit) {
        flag = false
        message = '请选择收集单位'
      }

      if (!flag) {
        this.$message({
          message: message,
          type: 'warning'
        })
        return false
      }
      return true
    },
    getNowDate () {
      let now = new Date()
      let year = now.getFullYear()
      let month = (now.getMonth() + 1).toString().padStart(2, '0')
      let day = now.getDate().toString().padStart(2, '0')
      return year + '-' + month + '-' + day
    },
    getCollectUnit (value) {
      this.dataForm.collectUnit = value
    },
    addRegister () {
      this.getOne();
      this.formEdit = 'add';
      this.formTitle = '新增保存登记';
      this.isReady = true;

      let dom = this;
      let selected = {};
      let getParent = function (pId) {
        if (pId) {
          let node = dom.$refs.treeList.getNode(pId);
          if (node && node.data) {
            let data = node.data;
            let module = data.module;
            selected[module] = data.id;
            getParent(data.parentId);
          }
        }
      }

      let selectedNode = this.selectedNode;
      if (selectedNode) {
        selected[selectedNode.module] = selectedNode.id;
        if (selectedNode.parentId) {
          getParent(selectedNode.parentId);
        }
      }

      if (Object.keys(selected).length > 0) {
        let oneId = selected.one;
        if (oneId) {
          this.$set(this.dataForm, 'oneId', oneId);
          this.getChildren(oneId).then(res => {
            this.twoData = res;
          });
        }

        let twoId = selected.two;
        if (twoId) {
          this.getChildren(twoId).then(res => {
            this.threeData = res;
            this.$set(this.dataForm, 'twoId', twoId);
          });
        }
        let threeId = selected.three;
        if (threeId) {
          this.getChildren(threeId).then(res => {
            this.fourData = res;
            this.$set(this.dataForm, 'threeId', threeId);
          });
        }

        if (selected.four) {
          this.$set(this.dataForm, 'fourId', selected.four);
        }
      }
      let user = JSON.parse(localStorage.getItem('user'));
      this.$set(this.dataForm, 'registrant', user.userName);
      this.$set(this.dataForm, 'registrantPhone', user.phone);
      this.$set(this.dataForm, 'registerUnit', user.departmentId);
      this.$set(this.dataForm, 'registerTime', this.getNowDate());

      this.registerVisible = true;
    },
    speciesChange (data) {
      let latinName
      let species = this.speciesMap[data]
      if (species) {
        latinName = species.latinName
      }
      this.$set(this.dataForm, 'speciesLdName', latinName)
    },
    cancel () {
      this.dataForm = {};
      this.fileList = [];
      this.disabled = false;
      this.registerVisible = false;
      this.isReady = false;

      this.oneData = [];
      this.twoData = [];
      this.threeData = [];
      this.fourData = [];
      this.$refs.lonRef.initData();
      this.$refs.latRef.initData();
    },
    //经度
    lonEvent(val){
      this.dataForm.lon = val;
    },

    latEvent(val){
      this.dataForm.lat = val;
    },

    lonDiChaEvent(val){
      this.surveyForm.lon = val;
    },
    latDiChaEvent(val){
      this.surveyForm.lat = val;
    },
    saveRegister () {
      if (this.validation()) {
        this.showLoading()
        let params = Object.assign({}, this.dataForm)
        params.type = this.dataForm.type ? this.dataForm.type.join(',') : null
        const formData = new FormData()
        if (this.fileList) {
          for (let i in this.fileList) {
            let file = this.fileList[i]
            if (!file.id) {
              formData.append('accessory', file.raw)
            }
          }
        }
        for (let key in this.dataForm) {
          if (key === 'parentIdArr' || key === 'fileList') continue
          let value = this.dataForm[key]
          if (value != null) {
            if (key === 'type') {
              formData.append(key, value.join(','))
            } else {
              formData.append(key, value)
            }
          }
        }
        resourceApi.saveRegisterPreservation(formData).then((res) => {
          this.hideLoading()
          if (res.data.message === 'success') {
            this.findPage()
            this.cancel()
            this.$notify({
              title: '消息',
              message: '保存成功！',
              position: 'bottom-right',
              showClose: false,
              type: 'success'
            })
          }
        })
      }
    },
    updateRegister (row) {
      this.formEdit = 'edit'
      this.formTitle = '修改保存登记'
      this.getInfo(row)
    },
    read (row) {
      this.disabled = true
      this.formEdit = 'read'
      this.formTitle = '查看保存登记'
      this.getInfo(row)
    },
    async getInfo (row) {
      this.getOne()
      let oneId = row.oneId
      if (oneId) {
        this.getChildren(oneId).then(res => {
          this.twoData = res
        })
      }
      let twoId = row.twoId
      if (twoId) {
        this.getChildren(twoId).then(res => {
          this.threeData = res
        })
      }
      let threeId = row.threeId
      if (threeId) {
        this.getChildren(threeId).then(res => {
          this.fourData = res
        })
      }
      this.findSpecies()
      this.findTemplate()
      const res = await resourceApi.getRegisterPreservationInfo(row.id)
      if (res.data.message === 'success') {
        this.dataForm = res.data.result
        this.chilLon = this.dataForm.lon;
          this.chilLat = this.dataForm.lat;
          this.isReady = true
        if (this.dataForm.type) {
          const arr = this.dataForm.type.split(',');
          this.dataForm.type = arr;
        }

        this.dataForm.fileList.forEach((item) => {
          item.url = this.fileServerUrl + item.path
          this.fileList.push(item)
        })
        this.registerVisible = true
      }
    },
    source (row) {
      this.findPageData(row)
    },
    findPageData (row) {
      resourceApi.getRegisterGatherInfo(row.registerGatherId).then((res) => {
        if (res.data.messageCode === '200') {
          this.gatherRowForm = res.data.result
          this.sourceVisible = true
        } else {
          this.gatherRowForm = []
        }
      })
    },
    showGather () {
      this.findGather()
      this.gatherVisible = true
    },
    queryGather () {
      this.gatherIndex = 1
      this.findGather()
    },
    findGather () {
      resourceApi.findRegisterGatherPage({
        pageSize: this.gatherSize,
        pageIndex: this.gatherIndex,
        grName: this.gatherForm.ggName,
        originalNo: this.gatherForm.originalNo
      }).then((res) => {
        let result = res.data.result
        if (res.data.message === 'success' && result) {
          this.gatherTableData = result.rows
          this.gatherTotalCount = result.totalCount
        } else {
          this.gatherTableData = []
          this.gatherTotalCount = 0
        }
      })
    },
    gatherPager (val) {
      this.gatherIndex = val
      this.findGather()
    },
    checkedTableRows (row, column, event) {
      this.dataForm.name = row.grName
      this.dataForm.registerGatherId = row.id
      this.$set(this.dataForm, 'speciesName', row.speName)
      this.$set(this.dataForm, 'speciesLdName', row.speLaName)
      this.cancelGather()
    },
    cancelGather () {
      this.gatherForm = {}
      this.gatherIndex = 1
      this.gatherTotalCount = 0
      this.gatherTableData = []
      this.gatherVisible = false
    },
    initCode (row) {
      this.tableRow = {}
      this.tableRow = row
      this.qrCodeVisible = true
      this.$nextTick(() => {
        this.$refs.qrCodeDiv.innerHTML = ''
        let curl = row.id.toUpperCase()
        QRCode.toCanvas(this.$refs.qrCodeDiv, curl, {
          width: 300,
          height: 300,
          colorDark: '#333333', // 二维码颜色
          colorLight: '#ffffff' // 二维码背景色
        }, function (error) {
          if (error) console.error(error)
        })
      })
    },
    addSurvey (row) {
      if (!row.templateId) {
        this.$message({
          message: '请先设置调查分类',
          type: 'warning'
        })
        return false
      }

      this.surveyEdit = true;
      this.surveyDisable = false;
      this.surveyTitle = '添加调查数据';
      this.surveyForm.name = row.name;
      this.surveyForm.type = row.type;
      this.isReady = true;

      this.$set(this.surveyForm, 'oneId', row.oneId);
      this.$set(this.surveyForm, 'twoId', row.twoId);
      this.$set(this.surveyForm, 'threeId', row.threeId);
      this.$set(this.surveyForm, 'fourId', row.fourId);

      this.$set(this.surveyForm, 'oneName', row.oneName);
      this.$set(this.surveyForm, 'twoName', row.twoName);
      this.$set(this.surveyForm, 'threeName', row.threeName);
      this.$set(this.surveyForm, 'fourName', row.fourName);

      this.$set(this.surveyForm, 'lon', row.lon);
      this.$set(this.surveyForm, 'lat', row.lat);
      this.$set(this.surveyForm, 'alt', row.alt);

      this.surveyForm.registerSaveId = row.id;
      this.surveyForm.templateId = row.templateId;
      this.surveyForm.number = new Date().Format('yyyyMMddhhmmss');
      this.getTemplate(row.templateId);
      this.surveyVisible = true;
    },
    getSurvey (row) {
      this.surveyEdit = false
      this.surveyTitle = '查看调查数据'
      this.surveyDisable = true
      this.getTemplate(row.templateId)
      this.getResourceInfo(row.id)
      this.surveyVisible = true
    },
    getResourceInfo (resourceId) {
      resourceApi.getResourceInfo(resourceId).then((res) => {
        let result = res.data.result
        if (res.data.message === 'success' && result) {
          this.surveyForm = result
          let dataJson = result.dataJson ? JSON.parse(result.dataJson) : {}
          for (let key in dataJson) {
            let value = dataJson[key]
            this.$set(this.dataJson, key, value)
          }
        }
      })
    },
    getTemplate (templateId) {
      this.templateDetails = []
      templateApi.findColumn(templateId).then((res) => {
        if (res.data.message === 'success' && res.data.result) {
          this.templateDetails = res.data.result
        } else {
          this.templateDetails = []
        }
      })
    },
    setFileList (data) {
      let fileList = []
      if (data) {
        let name = data.substring(data.lastIndexOf('/') + 1, data.length)
        fileList.push({
          name: name,
          url: this.fileServerUrl + data
        })
      }
      return fileList
    },
    handleExceed (files, fileList) {
      this.$message.warning('只能选择一个文件')
    },
    uploadFile (file) {
      let formData = new FormData()
      formData.append('file', file.file)
      formData.append('folder', 'resource')
      resourceApi.uploadFile(formData).then((res) => {
        if (res.data.message === 'success') {
          this.dataJson[file.filename] = res.data.result
        }
      })
    },
    saveSurvey () {
      if (!this.surveyForm.number) {
        this.$message({
          message: '请输入植株编号',
          type: 'warning'
        })
        return false
      }
      if (!this.surveyForm.oneId) {
        this.$message({
          message: '请选择保存库',
          type: 'warning'
        })
        return false
      }
      if (!this.surveyForm.twoId) {
        this.$message({
          message: '请选择保存区',
          type: 'warning'
        })
        return false
      }
      if (!this.surveyForm.threeId) {
        this.$message({
          message: '请选择隶属大类',
          type: 'warning'
        })
        return false
      }
      if (!this.surveyForm.fourId) {
        this.$message({
          message: '请选择小区',
          type: 'warning'
        })
        return false
      }
      this.showLoading()
      this.surveyForm.dataJson = this.dataJson ? JSON.stringify(this.dataJson) : null
      resourceApi.saveResource(this.surveyForm).then((res) => {
        this.hideLoading()
        if (res.data.message === 'success') {
          this.$notify({
            title: '消息',
            message: ('保存成功！'),
            position: 'bottom-right',
            showClose: false,
            type: 'success'
          })
          this.isReady = false;
          this.cancelSurvey()
        } else {
          this.$notify.error({
            title: '消息',
            message: '保存失败'
          })
        }
      })
    },
    cancelSurvey () {
      this.active = '1';
      this.oneData = [];
      this.twoData = [];
      this.threeData = [];
      this.fourData = [];
      this.dataJson = {};
      this.surveyForm = {};
      this.surveyEdit = false;
      this.surveyVisible = false;
    },
    showResource (registerSaveId, edit) {
      this.registerSaveId = registerSaveId
      this.resourceEdit = edit
      this.findResource()
      this.resourceVisible = true
    },
    findResource () {
      resourceApi.findResourcePage({
        registerSaveId: this.registerSaveId,
        pageSize: this.resourceSize,
        pageIndex: this.resourceIndex
      }).then((res) => {
        let result = res.data.result
        if (res.data.message === 'success' && result) {
          this.resourceTableData = result.rows
          this.resourceTotalCount = result.totalCount
          if (this.evaluateForm.resourceNumber) {
            this.$nextTick(() => {
              let number = this.evaluateForm.resourceNumber.split(',')
              if (number) {
                for (let i in number) {
                  this.resourceTableData.forEach(row => {
                    let obj = JSON.parse(row.dataJson)
                    row.zheight = obj['树高（m）']
                    row.dbh = obj['胸径（m）']
                    row.pew = obj['冠幅（m,东西）']
                    row.psn = obj['冠幅（m,南北）']

                    if (number[i] === row.number) {
                      this.$refs.resourceTable.toggleRowSelection(row, true)
                    }
                  })
                }
              }
            })
          }
        } else {
          this.resourceTableData = []
          this.resourceTotalCount = 0
        }
      })
    },
    resourcePager (val) {
      this.resourceIndex = val
      this.findResource()
    },
    cancelResource () {
      this.oneData = [];
      this.twoData = [];
      this.threeData = [];
      this.fourData = [];
      this.registerSaveId = null;
      this.resourceIndex = 1;
      this.resourceTableData = [];
      this.resourceTotalCount = 0;
      this.multipleSelection = [];
      this.resourceVisible = false;
    },
    handleSelection (selection, row) {
      let index = this.multipleSelection.indexOf(row.number)
      if (index < 0) {
        this.multipleSelection.push(row.number)
      } else {
        this.multipleSelection.splice(index, 1)
      }
    },
    handleSelectionAll (selection) {
      if (selection.length > 0) {
        selection.forEach((item) => {
          if (this.multipleSelection.indexOf(item.number) < 0) {
            this.multipleSelection.push(item.number)
          }
        })
      } else {
        this.resourceTable.forEach((item) => {
          this.multipleSelection.splice(this.multipleSelection.indexOf(item.number), 1)
        })
      }
    },
    selectionChange (val) {
      if (val && val.length > 0) {
        let avgHigh = 0
        let avgDbh = 0
        let avgPew = 0
        let avgPsn = 0
        for (let i in val) {
          let item = val[i]
          let obj = JSON.parse(item.dataJson)
          let zheight = obj['树高（m）']
          let dbh = obj['胸径（m）']
          let pew = obj['冠幅（m,东西）']
          let psn = obj['冠幅（m,南北）']

          avgHigh += typeof (zheight) === 'undefined' ? 0 : parseInt(zheight)
          avgDbh += typeof (dbh) === 'undefined' ? 0 : parseInt(dbh)
          avgPew += typeof (pew) === 'undefined' ? 0 : parseInt(pew)
          avgPsn += typeof (psn) === 'undefined' ? 0 : parseInt(psn)
        }
        avgHigh = avgHigh / val.length
        avgDbh = avgDbh / val.length
        avgPew = avgPew / val.length
        avgPsn = avgPsn / val.length
        this.evaluateForm.avgHigh = avgHigh
        this.evaluateForm.avgDbh = avgDbh
        this.evaluateForm.avgPew = avgPew
        this.evaluateForm.avgPsn = avgPsn
      }
    },
    getNumber () {
      let number = []
      this.multipleSelection.forEach(selion => {
        number.push(selion)
      })
      this.evaluateForm.resourceNumber = number.join(',')
      this.cancelResource()
    },
    async addEvaluate (row) {
      let speciesName = row.speciesName
      if (speciesName) {
        let name, family, purpose;
        let species = this.speciesMap[speciesName];
        if (species) {
          purpose = species.purpose;
          let speciesLatin = species.latinName;
          let familyName = species.familyName;
          let familyLatin = species.familyLatinName;
          name = speciesName + (speciesLatin ? '、' + speciesLatin : '');
          family = familyName ? familyName + (familyLatin ? '、' + familyLatin : '') : '';
        }

        this.$set(this.evaluateForm, 'name', speciesName);
        this.$set(this.evaluateForm, 'specificName', name);
        this.$set(this.evaluateForm, 'familyName', family);
        this.$set(this.evaluateForm, 'purpose', purpose);
      }

      if (row.oneId) {
        this.$set(this.evaluateForm, 'oneId', row.oneId);
        this.$set(this.evaluateForm, 'oneName', row.oneName);
      }

      if (row.twoId) {
        this.$set(this.evaluateForm, 'twoId', row.twoId);
        this.$set(this.evaluateForm, 'twoName', row.twoName);
      }

      if (row.threeId) {
        this.$set(this.evaluateForm, 'threeId', row.threeId);
        this.$set(this.evaluateForm, 'threeName', row.threeName);
      }

      if (row.fourId) {
        this.$set(this.evaluateForm, 'fourId', row.fourId);
        this.$set(this.evaluateForm, 'fourName', row.fourName);
      }

      this.evaluateForm.registerGatherId = row.id;
      this.$set(this.evaluateForm, 'germplasmName', row.name);
      this.$set(this.evaluateForm, 'lon', row.lon);
      this.$set(this.evaluateForm, 'lat', row.lat);
      this.$set(this.evaluateForm, 'alt', row.alt);
      this.$set(this.evaluateForm, 'saveTime', row.saveTime);
      this.$set(this.evaluateForm, 'germplasmType', row.type);
      this.evaluateVisible = true;
    },
    saveEvaluate () {
      if (!this.evaluateForm.name) {
        this.$message({
          message: '请输入物种名称',
          type: 'warning'
        })
        return false
      }
      this.showLoading()
      let params = Object.assign({}, this.evaluateForm)
      resourceApi.saveEvaluate(params).then((res) => {
        this.hideLoading()
        if (res.data.message === 'success') {
          this.$notify({
            title: '消息',
            message: ('评测成功！'),
            position: 'bottom-right',
            showClose: false,
            type: 'success'
          })
          this.cancelEvaluate()
        } else {
          this.$notify.error({
            title: '消息',
            message: '评测失败'
          })
        }
      })
    },
    cancelEvaluate () {
      this.evaluateForm = {};
      this.evaluateVisible = false;
    },
    remove (row) {
      let tips = ''
      if (row) {
        tips = `此操作将删除: ${row.name}, 是否继续?`
      } else {
        return
      }
      this.$confirm(tips, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.showLoading()
        resourceApi.deleteRegisterPreservation(row.id).then((res) => {
          this.hideLoading()
          if (res.data.message === 'success') {
            this.$notify({
              title: '消息',
              message: ('删除成功！'),
              position: 'bottom-right',
              showClose: false,
              type: 'success'
            })
            this.findPage()
          }
        })
      })
    },
    showLoading () {
      this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
    },
    hideLoading () {
      this.$loading().close()
    },
    initBtn () {
      let permissionBtn = JSON.parse(localStorage.permissionBtn)
      this.addBtn = permissionBtn['save_register_add']
      this.updateBtn = permissionBtn['save_register_update']
      this.deleteBtn = permissionBtn['save_register_delete']
      this.importBtn = permissionBtn['save_register_import']
      this.exportBtn = permissionBtn['save_register_export']
      this.codeBtn = permissionBtn['save_register_code']
      this.surveyBtn = permissionBtn['save_register_survey']
      this.evaluationBtn = permissionBtn['save_register_evaluation']
      this.migrationBtn = permissionBtn['save_register_migration']
    },
    downloadExcel () {
      resourceApi.downloadExcel('/gr/register/save/downloadExcel', null)
    },
    beforeUpload (file) {
      let flag = false
      let name = file.name
      if (name.indexOf('.') > -1) {
        let suffix = name.substring(name.lastIndexOf('.') + 1, name.length)
        if (suffix === 'xls' || suffix === 'xlsx') {
          flag = true
        }
      }
      if (!flag) {
        this.$message({
          message: '只能上传xls/xlsx文件',
          type: 'warning'
        })
      } else {
        this.showLoading()
      }
      return flag
    },
    handleSuccess (res, file, fileList) {
      this.hideLoading()
      if (res.message === 'success') {
        this.findPage()
        this.importVisible = false
        this.$message({
          message: '导入成功',
          type: 'success'
        })
      } else {
        let message = res.message
        if (message && message.indexOf(':') > -1) {
          message = message.substring(message.lastIndexOf(':') + 1, message.length)
        }
        this.$message.error(message ? message : '导入失败')
      }
    },
    handleSelect (selection, row) {
      let id = row.id
      let checked = false
      for (let i in selection) {
        let item = selection[i]
        if (item.id === id) {
          checked = true
          break
        }
      }
      if (checked) {
        this.onlyId.push(id)
      } else {
        let index = this.onlyId.indexOf(id)
        this.onlyId.splice(index, 1)
      }
    },
    handleSelectAll (selection) {
      if (selection.length > 0) {
        for (let i in selection) {
          let item = selection[i]
          if (this.onlyId.indexOf(item.id) === -1) {
            this.onlyId.push(item.id)
          }
        }
      } else {
        let data = this.tableData
        for (let i in data) {
          let item = data[i]
          let index = this.onlyId.indexOf(item.id)
          if (index !== -1) {
            this.onlyId.splice(index, 1)
          }
        }
      }
    },
    clearSelection () {
      this.onlyId = []
      this.$refs.multipleTable.clearSelection()
    },
    handleChange (file, fileList) {
      this.fileList.push(file)
      if(!((file.raw.type === 'image/png' || file.raw.type === 'image/gif' || file.raw.type === 'image/jpg' || file.raw.type === 'image/jpeg' || file.raw.type === 'image/PNG' || file.raw.type === 'image/JPG' || file.raw.type === 'image/JPEG'))){
        this.handleRemove(file);
        this.$message({
          message: '只能上传图片文件',
          type: 'warning'
        });
      }
    },
    handlePictureCardPreview (file) {
      this.dialogImageUrl = this.fileServerUrl + file.url
      this.dialogVisible = true
    },
    handleRemove (file) {
      if (file.id) {
        this.$confirm('确定删除该附件吗？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          resourceApi.delGatherPic(file.id).then((res) => {
            if (res.data.messageCode === '200') {
              this.$notify({
                title: '消息',
                message: '删除成功！',
                position: 'bottom-right',
                showClose: false,
                type: 'success'
              })
              for (let i in this.fileList) {
                let item = this.fileList[i]
                if (item.id === file.id) {
                  this.fileList.splice(i, 1)
                  break
                }
              }
            }
          })
        })
      } else {
        this.fileList.forEach((item, index) => {
          if (item.uid === file.uid) {
            this.fileList.splice(index, 1)
          }
        })
      }
    },
    async exportTmpVal (isAll) {
      if (!isAll) {
        if (this.onlyId.length === 0) {
          this.$message({
            message: '请选择需要导出的数据',
            type: 'warning',
          })
          return false
        }
      }

      let loading = this.$loading({
        lock: true,
        text: '数据导出中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })

      let params = {
        isAll: isAll,
        onlyId: this.onlyId,
        name: this.queryForm.speciesName,
        growthEvaluation: this.queryForm.growthEvaluation,
        economicEvaluation: this.queryForm.economicEvaluation
      }
      if (this.selectedNode) {
        let id = this.selectedNode.id
        let index = id.indexOf('_')
        if (index > -1) {
          let moduleIds = id.split('_')
          params.oneId = moduleIds[0] ? moduleIds[0] : null
          params.twoId = moduleIds[1] ? moduleIds[1] : null
          params.threeId = moduleIds[2] ? moduleIds[2] : null
          params.fourId = moduleIds[3] ? moduleIds[3] : null
        } else {
          params.oneId = id
        }
      }
      let url = '/gr/register/save/exportExcel'
      await resourceApi.downloadExcel(url, params)
      loading.close()
      this.clearSelection()
    },
    deleteBatch() {
      if (this.onlyId.length === 0) {
        this.$message({
          message: '请选择需要删除的数据',
          type: 'warning',
        })
        return false
      }

      let tips = `确定要删除吗?`
      this.$confirm(tips, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.showLoading()
        resourceApi.deleteRegisterSaveBatch({ids: this.onlyId}).then((res) => {
          this.hideLoading()
          if (res.data.message === 'success') {
            this.findPage();
            this.$notify({
              title: '消息',
              message: ('删除成功！'),
              position: 'bottom-right',
              showClose: false,
              type: 'success'
            })
          }
        });
      });
    },
    dataMigration(command) {
      if (command) {
        if (this.totalCount === 0) {
          this.$message({
            message: '暂无可迁移数据',
            type: 'warning',
          });
          return false;
        }
      } else {
        if (this.onlyId.length === 0) {
          this.$message({
            message: '请选择需要迁移的数据',
            type: 'warning',
          });
          return false;
        }
      }

      this.getOne();
      let dom = this;
      let selected = {};
      let getParent = function (pId) {
        if (pId) {
          let node = dom.$refs.treeList.getNode(pId);
          if (node && node.data) {
            let data = node.data;
            let module = data.module;
            selected[module] = data.id;
            getParent(data.parentId);
          }
        }
      }

      let selectedNode = this.selectedNode;
      if (selectedNode) {
        selected[selectedNode.module] = selectedNode.id;
        if (selectedNode.parentId) {
          getParent(selectedNode.parentId);
        }
      }

      if (Object.keys(selected).length > 0) {
        let oneId = selected.one;
        if (oneId) {
          this.$set(this.migration, 'oneId', oneId);
          this.getChildren(oneId).then(res => {
            this.twoData = res;
          });
        }

        let twoId = selected.two;
        if (twoId) {
          this.getChildren(twoId).then(res => {
            this.threeData = res;
            this.$set(this.migration, 'twoId', twoId);
          });
        }
        let threeId = selected.three;
        if (threeId) {
          this.getChildren(threeId).then(res => {
            this.fourData = res;
            this.$set(this.migration, 'threeId', threeId);
          });
        }

        if (selected.four) {
          this.$set(this.migration, 'fourId', selected.four);
        }
      }
      this.migration.isAll = command;
      this.migrationVisible = true;
    },
    migrationCancel() {
      this.migration = {};
      this.migrationVisible = false;
    },
    saveMigration() {
      let flag = true;
      let message = null;
      if (!this.migration.oneId) {
        message = '请选择保存库';
      }
      if (flag && !this.migration.twoId) {
        flag = false
        message = '请选择保存区'
      }
      if (flag && !this.migration.threeId) {
        flag = false
        message = '请选择隶属大类'
      }
      if (flag && !this.migration.fourId) {
        flag = false
        message = '请选择小区'
      }

      if (!flag) {
        this.$message({
          message: message,
          type: 'warning'
        });
        return false;
      }

      this.$confirm('数据迁移后将无法还原，确定要迁移吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.showLoading();
        this.migration.onlyId = this.onlyId;
        this.migration.form = this.queryForm;
        resourceApi.saveMigration(this.migration).then(res => {
          this.hideLoading();
          if (res.data.message === 'success') {
            this.findPage();
            this.migrationCancel();
            this.$notify({
              title: '消息',
              message: ('迁移成功！'),
              position: 'bottom-right',
              showClose: false,
              type: 'success'
            });
          }
        });
      }).catch(() => {})
    }
  }
}
</script>
<style lang="less" scoped>
.form-table {
  width: 100%;

  table,
  tr,
  td {
    border: 1px solid #fff;
  }

  td {
    &:nth-child(even) {
      width: 32%;
    }

    &:nth-child(odd) {
      text-indent: 10px;
    }
  }

  /deep/ .el-input__inner {
    border: none;
  }

  /deep/ .el-textarea__inner {
    border: none;
  }
}

.dialog-footer {
  .paging {
    margin-top: 0px;
  }
}

.el-form-item__label {
  padding: 0 20px 0 0 !important;
}

.container {
  height: 100vh;
  display: flex;
  box-sizing: border-box;
}

.leftNaV {
  box-sizing: border-box;
  color: #ffffff;
  width: 13%;
  min-width: 240px;
  background: rgba(24, 32, 45, 0.2);
  height: calc(100vh - 190px);
  max-height: calc(100vh - 190px);
  display: flex;
  justify-content: center;
  border: 1px solid rgba(0, 245, 255, 0.5);
  position: relative;

  /deep/ .el-tree {
    width: 100%;
    font-size: 2rem;
    text-align: left;
    padding: 15px 15px;
    cursor: pointer;
    white-space: nowrap;
    overflow-x: hidden;
    cursor: pointer;
    text-overflow: ellipsis;
  }
}

.rightContent {
  font-size: 2.2rem;
  margin-left: 2%;
  width: calc(100% - 240px - 2%);
  height: calc(100vh - 250px);
  /*background-color: red;*/
}

.search {
  & /deep/ .el-form-item__label {
    font-size: 1.8rem;
  }

  & /deep/ .el-input--suffix .el-input__inner {
    padding-right: 0px;
  }
}

.el-form-item__label {
  padding: 0 20px 0 0 !important;
}

& /deep/ .el-pagination .el-select .el-input .el-input__inner {
  border: 1px solid #FFFFFF;
}

& /deep/ .el-pagination__editor.el-input .el-input__inner {
  border: 1px solid #FFFFFF;
}

.content {
  margin-top: 10px;

  & /deep/ .el-checkbox__inner {
    height: 20px;
    width: 20px;
    font-size: 28px;
    font-weight: 400;
    color: rgba(255, 255, 255, 1);
    background: none;
  }

  & /deep/ .el-tooltip__popper {
    background-color: red;
  }

  & /deep/ .el-checkbox__inner::after {
    border-width: 2px;
    /* border-color: black; */
    height: 6px;
    left: 6px;
    top: 3px;
    width: 4px;
  }

  & /deep/ .el-checkbox__input.is-indeterminate .el-checkbox__inner::before {
    top: 8px;
    background: white;
  }
}

.line {
  display: inline-flex;
  height: 21px;
  width: 1px;
  background: rgba(0, 255, 255, 1);
  margin: 0 10px;
  vertical-align: middle;
}

.dialogBtn {
  font-size: 1.6rem;

  &:hover {
    background: rgba(12, 161, 151, 1);
  }
}

.coordinate {
  width: 30%;
}

/deep/ .el-tree-node__content {
  height: 40px;
}

/deep/ .el-tree-node__expand-icon {
  font-size: 16px;
}

/deep/ .el-tree-node__label {
  font-size: 18px;
  letter-spacing: 3px;
}

/deep/ .custom-tree-node {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

/deep/ .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
  box-shadow: inset 0 0 15px #00f5ff;
}

.p-frame {
  -webkit-appearance: none;
  background-color: transparent;
  background-image: none;
  border-radius: 4px;
  border: 1px solid #FFFFFF;
  color: #FFF;
}

.table-tr1 {
  height: 35px;
  border-bottom: 1px solid #D3D3D3;
}

.table-tr2 {
  height: 35px;

}

.table-td1 {
  color: #D3D3D3;
  font-weight: bold;
  font-size: 16px;
  padding: 8px 5px 12px 0;
  border-bottom: 1px solid #D3D3D3;
}

.table-td2 {
  width: 20%;
  color: #D3D3D3;
  font-size: 15px;
  padding: 8px 5px 12px 11px;
  border-right: 1px solid #D3D3D3;
}

.table-td3 {
  width: 30%;
  color: #D3D3D3;
  font-size: 15px;
  border-right: 1px solid #D3D3D3;
}

.table-td4 {
  width: 19.6%;
  color: #D3D3D3;
  font-size: 15px;
  padding: 8px 5px 12px 11px;
  border-right: 1px solid #D3D3D3;
}

.table-td5 {
  width: 80.4%;
  color: #D3D3D3;
  font-size: 15px;
  border-right: 1px solid #D3D3D3;
}

.td-input {
  width: 100%;
  height: 35px;
  outline: 0;
  border: 0;
  background: 0 0;
}

/deep/ .el-form-item__content {
  .el-date-editor {
    border: 1px solid #FFFFFF;
  }
}

/deep/ .el-input__inner {
  width: 100%;
  color: #FFFFFF;
  font-size: 1.5rem;
  border: 0;
  background-color: #32f1ff16;
  margin-top: 1px;
}

/deep/ .el-collapse {
  outline: 0;
  border: 0;
}

/deep/ .el-collapse-item__header {
  width: 100%;
  height: 35px;
  line-height: 35px;
  background-color: transparent;
  color: #FFF;
  cursor: pointer;
  border: 0;
}

/deep/ .el-collapse-item__content {
  padding-bottom: 0px;
  font-size: 13px;
  color: #FFF;
  border-bottom: 0;
}

/deep/ .el-collapse-item__wrap {
  background-color: transparent;
  border-bottom: 0;
}

/deep/ .el-collapse-item__header {
  font-size: 16px;
  padding-left: 11px;
  border-bottom: 1px solid #D3D3D3;
  width: 98.9%;
}

/deep/ .el-collapse-item__header.is-active {
  font-size: 16px;
  padding-left: 11px;
}

/deep/ .el-collapse-item__arrow {
  margin-right: 35px;
}

/deep/ .el-collapse-item__arrow.is-active {
  margin-right: 35px;
}

/deep/ .table-select {
  width: 180px;
  height: 35px;
  border: 1px solid #fff;
  background: 0 0;
  color: #D3D3D3;
}

.qr-ul {
  width: 100%;
  display: flex;
  flex-direction: row;
  border: 1px solid #D3D3D3;
}

.dynamic {
  .qr-ul div {
    width: 100%;
    display: flex;
    flex-direction: row;
  }
}

.import {
  /deep/ .el-dialog__body {
    border-bottom: 1px solid #1f5aab;
  }
}

/deep/ .el-dropdown-menu__item:focus,
.el-dropdown-menu__item:not(.is-disabled):hover {
  color: #ffffff;
  background-color: #32f1ff16;
}
</style>
<style lang="less">
/**
     * 修改样式   覆盖默认的饿了么全局样式
     */
.el-upload-dragger {
  background-color: transparent;
}

.el-form-item__label {
  padding: 0 20px 0 0 !important;
}

.td3-box {
  display: flex;
  justify-content: space-between;
  line-height: 45px;
  margin-left: 5px;
  margin-right: 5px;
}
.coordinate-type{
  width: 25%;
}
</style>
